package com.atwei.mango.business.hello.mapper;

import com.atwei.mango.business.hello.entity.Hello;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * @author liuwei
 * @date 2021/10/16 20:40
 */
@Mapper
public interface HelloMapper extends BaseMapper<Hello> {
    /**
     * 通过id获取
     * @param id
     * @return
     */
    Hello getByIdCustom(@Param("id") int id);

    /**
     *测试mybatis-plus分页插件
     * @param [page]
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.atwei.mango.business.hello.entity.Hello>
     * @throws
     * @author liuwei
     * @date 2021/10/23 10:59
     */
    IPage<Hello> selectPageCustom(@Param("page") Page<Hello> page);

    /**
     *测试wrapper自定义sql
     * @param [wrapper]
     * @return java.util.List<com.atwei.mango.business.hello.entity.Hello>
     * @throws
     * @author liuwei
     * @date 2021/10/23 11:08
     */
    @Select("select * from hello o ${ew.customSqlSegment}")
    List<Hello> selectListWrapperCustom(@Param(Constants.WRAPPER)Wrapper<Hello> wrapper);

    /**
     *测试分页和自定义Wrapper
     * @param [page, wrapper]
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.atwei.mango.business.hello.entity.Hello>
     * @throws
     * @author liuwei
     * @date 2021/10/23 11:24
     */
    IPage<Hello> selectPageWrapperCustom(@Param("page") Page<Hello> page,@Param(Constants.WRAPPER)Wrapper<Hello> wrapper);

}
